﻿--HEADER Drop iPerform Stored Procedures, Remove columns ('StrategyInitTemplateId', 'AsoluteRelative', 'Private') from Idea table and JoinedIdea view
GO
DROP PROCEDURE [iPerform].[GetAnswerGridQuestionGroupIds];

GO
DROP PROCEDURE [iPerform].[GetInitTemplates];

GO
DROP PROCEDURE [iPerform].[GetLastRevisionTemplateQuestionIds];

GO
DROP PROCEDURE [iPerform].[GetTemplateHistory];

GO
DROP PROCEDURE [iPerform].[GetTemplatesForQuestionGroup];


GO
DROP PROCEDURE [iPerform].[GetUserFundBookEntities];

GO
DROP PROCEDURE [iPerform].[InitTradesToTemplateAnswerStartDates];

GO
ALTER TABLE [iPerform].[Idea] DROP COLUMN [AbsoluteRelative], COLUMN [Private], COLUMN [StrategyInitTemplateId];

GO
ALTER VIEW [iPerform].[JoinedIdea]
	AS  SELECT        Analytics.Idea.Id, Analytics.Idea.FundBookEntityId, Analytics.Idea.Type, Idea_1.OwnerUserId, Idea_1.Name, 
								 CASE WHEN Closed IS NOT NULL THEN Closed 
								 ELSE ~HasOpenPosition  END 
								 AS Closed
		FROM            Analytics.Idea 
		LEFT JOIN
								 iPerform.Idea AS Idea_1 ON Analytics.Idea.Id = Idea_1.Id

